/*
 *      Author: Guannan Ma
 *      @mythmgn
 *      Whatever license applied
 */

#include "base.h"

#ifndef BASE_LIB_LIBBST_H
#define BASE_LIB_LIBBST_H

#ifdef	__cplusplus
extern "C"
{
#endif

    /** 
     * @brief 
     *     Binary Tree Structure
     */
typedef struct BST{
    struct BST *p_left;
    struct BST *p_right;
    void *p_data;
    char *p_key;
    unsigned int length;
}BST;

/*!
 * @brief Initialize the Binary Tree
 *
 * @return  BST* 
 * @retval  The pointer to the Binary Tree 
**/
BST* initBST();

/**
 * @brief 
 *
 * @param [in/out] p_bst   : BST*
 * @param [in/out] p_key   : char*
 * @param [in/out] p_data   : void*
 * @param [in/out] compareData)(char*insertKey   : int (*
 * @param [in/out] bstKey)   : char*
 * @param [in/out] specialHandle)(BST*p_bst   : BOOL (*
 * @param [in/out] p_key)   : char*
 * @return  int 
 * @retval   
**/
int insertBSTNode(BST* p_bst,char *p_key, void *p_data,int (*compareData)(char *insertKey,char *bstKey),BOOL (*specialHandle)(BST *p_bst,char *p_key));

/* TODO: Does not implemented yet.*/
char ** traverseBSTKey(BST *p_bst);
BOOL closeTraverse(void *p_value);

/**
 * @brief 
 *
 * @note 
 * @param [in/out] p_bst   : BST*
 * @param [in/out] BOOL (*freeContent)(void*data)   : BOOL
 * @return  BOOL 
 * @retval   
**/
BOOL freeBST(BST *p_bst,BOOL(*freeContent)(void *data));

#ifdef __cplusplus
}
#endif

#endif // LIB_BST_H_INCLUDED
